package com.admin.education.controllers.system;

import com.admin.education.common.jwt.JwtAuthorize;
import com.admin.education.dataTransferObject.ServicesExcuteResult;
import com.admin.education.dataTransferObject.menus.MenusTree;
import com.admin.education.services.Interfaces.IMenusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

@RestController
@RequestMapping("/menus")
@CrossOrigin(origins = "*", maxAge = 3600)
@JwtAuthorize
public class MenusController {
    @Autowired
    IMenusService menusService;
    @GetMapping("")
    public Callable<MenusTree> queryMenuAsync(){
        return  new Callable<MenusTree>() {
            @Override
            public MenusTree call() throws Exception {
                ServicesExcuteResult<MenusTree> result = menusService.queryMenuTree();
                return  result.getData();
            }
        };
    }
}
